//

require(["jquery","template"],function($,template){
    var URL = 'http://192.168.1.112:8080/followup/service';
    //var map1 = new BMap.Map("allmap");
    //var point1 = new BMap.Point(117.298452,31.839682);
    //map1.centerAndZoom(point1, 15);
    //var marker = new BMap.Marker(point1);  // 创建标注
    //map1.addOverlay(marker);               // 将标注添加到地图中
    //marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
    //map1.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
    //marker.addEventListener("click", function(){
    //    this.openInfoWindow(infoWindow);
    //    //图片加载完毕重绘infowindow
    //    document.getElementById('imgDemo').onload = function (){
    //        infoWindow.redraw();   //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
    //    }
    //});
    /**
     * 处理数据
     * @param data 后台获取的数据
     * @param k    数据类型
     * @returns {{rows: Array}}
     */
    function setData(data,k) {
        var res = [];
        for (var i = 0; i < data.data.length; i++) {
            if (data.data[i].platType == k) {
                res.push(data.data[i]);
            }
        }
        var data = {
            rows: res
        }

        return data;
    }
    //简介模块
    $.ajax({
        url: URL + "/department/basicinfo/detail",
        type:"post",
        contentType: "application/json;charset=UTF-8",
        dataType:"json",
        data:JSON.stringify({
            data : {
                "deptId":"YHDZgkDnxU3PCRtc5T"
            }
        }),
        success: function(data){
            //console.log(data);
            var html=template("one-p",data);
            $("#one-s").html(html);
            $("#top-log").attr('src',data.data.hospIcon);
            $(".introduction img").attr('src',data.data.hospPicture);
        },
        error: function(data){
            console.log('请求出错'+data);
        }
    });
    //挂号模块
    $.ajax({
        url: URL + "/department/register/detail",
        type:"post",
        contentType: "application/json;charset=UTF-8",
        dataType:"json",
        data:JSON.stringify({
            data : {
                "deptId":"YHDZgkDnxU3PCRtc5T"
            }
        }),
        success: function(data){
            var html1=template("line-appointment-h",setData(data,0));
            $("#line-appointment").html(html1);
            var html2=template("tel-appointment-h",setData(data,1));
            $("#tel-appointment").html(html2);
            var html3=template("wx-appointment-h",setData(data,2));
            $(".wx-appointment").html(html3);
            var pic=setData(data,2).rows[0].picture;
            $(".ewm img").attr("src",pic);
        },
        error: function(data){
            console.log('请求出错'+data);
        }
    });
    $.ajax({
        url: URL + "/department/contact/detail",
        type:"post",
        contentType: "application/json;charset=UTF-8",
        dataType:"json",
        data:JSON.stringify({
            data : {
                "deptId":"YHDZgkDnxU3PCRtc5T"
            }
        }),
        success: function(data){
            console.log(data);
            var html=template("hos-address",data);
            console.log(html);
            $(".hos-address1").html(html)
        },
        error: function(data){
            console.log('请求出错'+data);
        }
    });
});